<?php

 /**
  * @package JooS
  * @subpackage Syntax_PHPackager
  */

  require_once "JooS/Syntax/Complex/Transition.php";
  require_once "JooS/Syntax/PHPackager/Operator/Interface.php";

  abstract class JooS_Syntax_PHPackager_Operator_Abstract extends JooS_Syntax_Complex_Transition implements JooS_Syntax_PHPackager_Operator_Interface {
    /**
     * @return string
     */
    public function compile() {
      $ret = parent::compile();
      if ($ret !== false) {
        $compiledOperators = $this->getCompiledOperators();
        if (isset($compiledOperators[$ret]))
          $ret = $compiledOperators[$ret];
      }
      return $ret;
    }

    /**
     * @return JooS_Syntax_Complex_Choose
     */
    public function createRule() {
      $parser = $this->getParser();

      $list = $this->getAllOperators();
      $rule = array();
      foreach ($list as $operator) {
        array_push($rule, $parser->createSyntax("Simple_Symbol", $operator));
      }

      return $parser->createSyntax("Complex_Choose", $rule);
    }
  }
